package com.juc.scheduledExecutorService.scheduledExecutorService9;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Run2 {

	/**
	 * setExecuteExistingDelayedTasksAfterShutdownPolicy(false)
	 * 作用：当对ScheduledThreadPoolExecutor执行了shutdown()方法时，
	 * 任务是否继续执行，默认值是true,也就是当调用了shutdown()方法时还是
	 * 继续执行，当用setExecuteExistingDelayedTasksAfterShutdownPolicy(false)
	 * 时任务不再运行了
	 */
	public static void main(String[] args) {
		ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
		Runnable runnable1 = new MyRunnable("A");
		Runnable runnable2 = new MyRunnable("B");
		executor.schedule(runnable1, 3, TimeUnit.SECONDS);
		executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
		executor.shutdown();
		System.out.println(" 已经shutDown了 ");
	}
}
